﻿using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;

namespace Sharp.Platform.Owin
{
    public class SharpSignInManager : SignInManager<SharpUser, Guid>
    {

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="userManager"></param>
        /// <param name="authenticationManager"></param>
        public SharpSignInManager(UserManager<SharpUser, Guid> userManager, IAuthenticationManager authenticationManager)
            : base(userManager, authenticationManager)
        {
        }

        public static SharpSignInManager Create(IdentityFactoryOptions<SharpSignInManager> options, IOwinContext context)
        {
            return new SharpSignInManager(context.GetUserManager<SharpUserManager>(), context.Authentication);
        }

        /// <summary>
        /// 根据用户名密码，验证用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="isPersistent"></param>
        /// <param name="shouldLockout"></param>
        /// <returns></returns>
        public override async Task<SignInStatus> PasswordSignInAsync(string userName, string password, bool isPersistent,
            bool shouldLockout)
        {
            var x = await base.PasswordSignInAsync(userName, password, isPersistent,
                shouldLockout);

            return x;
        }
    }
}